package com.weng.bigdata.micro.service.warehouse.adapter.feign;

import com.weng.bigdata.micro.service.common.ServicesConstants;
import com.weng.bigdata.micro.service.warehouse.adapter.fallback.WarehouseQueryFallBack;
import com.weng.bigdata.micro.service.warehouse.adapter.model.req.QueryBySqlReq;
import com.weng.bigdata.micro.service.warehouse.adapter.model.req.QueryByTableReq;
import com.weng.framework.core.model.ResponseData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 查询引擎API
 * @author wengzhonghui
 * @date 11:00 2021/4/2
 */
@FeignClient(name = ServicesConstants.WAREHOUSE_ADAPTER_API_SERVER_NAME, fallback = WarehouseQueryFallBack.class, configuration = WarehouseQueryFallBack.class)
public interface WarehouseQueryFeignService {

		String URL_PREFIX = "/query";

		@PostMapping(URL_PREFIX + "/sql")
		ResponseData queryBySqlAndParam(@RequestBody QueryBySqlReq queryReq);

		/**
		 * 异步执行查询sql
		 * @param queryReq
		 * @return 返回异步任务Id
		 */
		@PostMapping(URL_PREFIX + "/sql/async")
		ResponseData queryBySqlAndParamAsync(@RequestBody QueryBySqlReq queryReq);

		/**
		 * 基于表查询
		 * @param queryReq
		 * @return
		 */
		@PostMapping(URL_PREFIX + "/table")
		ResponseData queryByTable(@RequestBody QueryByTableReq queryReq);

}
